/*
 * Common.h
 *
 *  Created on: 2011-7-6
 *      Author: gexiao
 */

#ifndef COMMON_H_
#define COMMON_H_

#ifndef LOG_TAG
# define LOG_TAG "dalvikvm"
#endif

#include <stdint.h>

#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))

typedef uint8_t u1;
typedef uint16_t u2;
typedef uint32_t u4;
typedef uint64_t u8;
typedef int8_t s1;
typedef int16_t s2;
typedef int32_t s4;
typedef int64_t s8;

/*
 * Storage for primitive types and object references.
 *
 * Some parts of the code (notably object field access) assume that values
 * are "left aligned", i.e. given "JValue jv","jv.i" and "*((s4*)&jv)"
 * yield the same result. This seems to be guaranteed by gcc on big- and
 * little-endian systems.
 */
typedef union JValue {
	u1 z;
	s1 b;
	u2 c;
	s2 s;
	s4 i;
	s8 j;
	float f;
	double d;
	void* l;
} JValue;

#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))

#define __BIG_ENDIAN 4321
#define __LITTLE_ENDIAN 1234
#if defined(HAVE_LITTLE_ENDIAN)
# define __BYTE_ORDER __LITTLE_ENDIAN
#else
# define __BYTE_ORDER __BIG_ENDIAN
#endif
#endif /* COMMON_H_ */
